﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Microsoft.SharePoint;

namespace TST.DemoCode.Domain
{
    public class Theme
    {
        public const String XmlNameSpaceThemes = "http://schemas.tonstegeman.com/themes/2010/03";

        public Theme()
        {
        }

        public String TemplateID
        {
            get;
            set;
        }

        private int _lcid;
        public String LCID
        {
            get
            {
                return _lcid.ToString();
            }
            set
            {

                int val = 0;
                if (!int.TryParse(value, out val))
                {
                    throw new Exception(String.Format("Value for attribute LCID in theme {0} is invalid: '{1}'.", TemplateID, value));
                }
                _lcid = val;
            }
        }


        public String DisplayName
        {
            get;
            set;
        }

        public String Description
        {
            get;
            set;
        }

        public String Thumbnail
        {
            get;
            set;
        }

        public String Preview
        {
            get;
            set;
        }

        public Boolean Validate()
        {
            if (String.IsNullOrEmpty(TemplateID))
                throw new SPException("TemplateID cannot be empty.");
            if (String.IsNullOrEmpty(DisplayName))
                throw new SPException("DisplayName cannot be empty.");
            if (String.IsNullOrEmpty(Thumbnail))
                throw new SPException("Thumbnail cannot be empty.");
            if (String.IsNullOrEmpty(Preview))
                throw new SPException("Preview cannot be empty.");
            if (_lcid<=0)
                throw new SPException("LCID must be a number greater than zero.");
            return true;
        }
    }
}
